﻿using MediatR;
using SystemMHB.API.Application.Command.LogisticsCommand;
using SystemMHB.Domian;
using SystemMHB.Infrstructer.Interface;

namespace SystemMHB.API.Application.CommandHandlers.LogisticsCommandHandler
{
    public class LogisticsSignForCommandHandler : IRequestHandler<LogisticsSignForCommand, int>
    {
        /// <summary>
        /// 物资信息仓储接口
        /// </summary>
        ILogisticsReposiyory _logistics;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="_logistics">物资信息仓储接口</param>
        public LogisticsSignForCommandHandler(ILogisticsReposiyory _logistics)
        {
            this._logistics = _logistics;
        }

        public async Task<int> Handle(LogisticsSignForCommand request, CancellationToken cancellationToken)
        {
            var qouer = await _logistics.GetModelAsync(request.orderID);
            qouer.orderTime = DateTime.Now.ToUniversalTime();
            qouer.logisticsType = 3;
            return await _logistics.UpdateAsync(qouer);
        }
    }
}
